﻿// See https://aka.ms/new-console-template for more information
using System.IO.Compression;

Console.WriteLine("Hello, World!");
// 源文件路径
string fileToCompress = @"D:\ACCT\logcenter\LCSServer\LCS-20240313.log";
// 目标ZIP文件路径
string zipFilePath = @"D:\ACCT\logzipcenter\20240313.zip";
// 确保目标ZIP文件不存在，如果存在，则删除
if (File.Exists(zipFilePath))
{
    File.Delete(zipFilePath);
}

using (ZipArchive zipArchive = new ZipArchive(File.Create(zipFilePath), ZipArchiveMode.Create))
{
    // 添加文件到ZipArchive
    zipArchive.CreateEntryFromFile(fileToCompress, "LCSServer\\" + Path.GetFileName(fileToCompress));
}

// 打印压缩后的ZIP文件路径
Console.WriteLine("ZIP文件已保存到: " + zipFilePath);
